
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>异常记录列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">

                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">

                        <div class="layui-inline layui-form">
                            <label class="layui-form-label">设备</label>
                            <div class="layui-input-block" style="width: 200px;">
                                <select name="deviceType">
                                    <option value="">请选择设备</option>
                                    <option value="0">洗车设备</option>
                                    <option value="1">入闸设备</option>
                                    <option value="2">出闸设备</option>
                                    <option value="3">出入同用闸设备</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">发生时间</label>
                            <div class="layui-input-block">
                                <div class="layui-inline">
                                    <input type="text" name="startCreateTime" class="layui-input time-select" placeholder="开始时间" autocomplete="off">
                                </div>
                                <div class="layui-inline">一</div>
                                <div class="layui-inline">
                                    <input type="text" name="endCreateTime" class="layui-input time-select" placeholder="结束时间" autocomplete="off">
                                </div>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">修复时间</label>
                            <div class="layui-input-block">
                                <div class="layui-inline">
                                    <input type="text" name="startRestoreTime" class="layui-input time-select" placeholder="开始时间" autocomplete="off">
                                </div>
                                <div class="layui-inline">一</div>
                                <div class="layui-inline">
                                    <input type="text" name="endRestoreTime" class="layui-input time-select" placeholder="结束时间" autocomplete="off">
                                </div>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"> 搜索</i>
                            </button>
                        </div>
                    </div>
                </div>

                <blockquote class="layui-elem-quote layui-quote-nm" style="font-size: 18px"><b>${name} ----  设备的历史异常记录</b></blockquote>

                <table class="layui-hide" id="test-table-reload" lay-filter="test-table-reload"></table>

            </div>
        </div>
    </div>
</div>
<input type="hidden" id="stationId" value="${stationId}">
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'utils', 'form', 'laydate'], function () {
        var $ = layui.$,
                table = layui.table,
                form = layui.form,
                laydate = layui.laydate,
                admin = layui.admin;

        //监听搜索
        form.on("submit(LAY-search)", function (data) {
            var field = data.field;

            //执行重载
            table.reload('test-table-reload', {
                where: field
            });
        });

        //时间选择器，同时绑定多个
        lay('.time-select').each(function () {
            laydate.render({
                elem: this
                , trigger: 'click'
                , theme: 'molv'
                , type: 'datetime'
            });
        });

        //方法级渲染
        table.render({
            elem: '#test-table-reload'
            , url: "/station/getFaultRecordList?stationId=" + $("#stationId").val()
            , toolbar: '#test-table-reload-toolbar'
            , defaultToolbar: ['filter']
            , cellMinWidth: 80
            , cols: [[
                {field: 'id', title: '序号', fixed: true}
                , {field: 'faultDeviceId', title: '设备ID', width: 260}
                , {field: 'deviceName', title: '异常设备', width: 260}
                , {field:'createTime', title: '异常发生时间',sort: true,templet: function (d) {
                        return "<div>"+layui.toDateString(d.createTime)+"</div>";
                    }}
                , {field:'restoreTime', title: '异常修复时间',sort: true, align:'center' ,templet: function (d) {
                        if (d.restoreTime > 0) {
                            return "<div style='text-align: center'>"+layui.toDateString(d.restoreTime)+"</div>";
                        } else {
                            return "<div style='text-align: center'>"+"-------"+"</div>";
                        }
                    }}
            ]]
            , page: true
            , height: 522
        });

    });
</script>
</body>
</html>